<?php
/*
 *Author: Panos
 *Soft deletes a category from the Database if the user
 *that tries to delete the entity is the owner of the category
 */

function BL_disableEntity($entityId, $userId)
{
	if($entityId < 0)
	{
		return BL_DISABLE_ENTITY;
	}

	/* Check if the user that tries to disable the entity is the category's owner */

	$entity = DB_getEntity($entityId);
	$category = DB_getCategory($entity->GetCategoryId());

	if($category->GetOwner() == $userId)
	{
		$err_no = DB_disableEntity($entityId);
		return $err_no >= 0 ? BL_OK : BL_DISABLE_ENTITY;
	}
	else
	{
		return BL_NOT_OWNER;
	}
}

?>